Repository navigation
fix(slack): show the agent server's error when a conversation fails to start (OHE-3564) - #1021
Merged
Merged
Conversation
…o start (OHE-3564)
When the agent server rejects a Slack-triggered conversation, for example
because a marketplace plugin's plugin.json lacks $schema and the plugin
fails to load, the Slack user only saw "Uh oh! There was an unexpected
error starting the job :(". The response body, which names the cause and
carries an error_id, was dropped on the way: the app server stored
httpx's status-and-URL string as the start task detail, and the Slack
views raised a plain RuntimeError for a failed start or a fixed Exception
for a rejected follow-up message, so start_job fell through to its
catch-all in both cases.
- Add agent_server_error_detail, which reads the agent server's
`exception` or `detail` field plus `error_id` and falls back to the
HTTP status alone, so the sandbox URL is never shown.
- Route httpx.HTTPStatusError through it in _exception_detail so a
rejected create reports the body's message in the start task detail.
- Raise StartingConvoException with that detail in the Slack views for a
failed start and for a rejected follow-up message; start_job already
posts that message in the thread.
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||
4 of 6 tasks
Contributor
|
🚀 Released in 1.81.0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HUMAN:
AGENT:
Why
When the agent server rejects a Slack-triggered conversation, the user only sees
Uh oh! There was an unexpected error starting the job :(. The reproduction in OHE-3564 is a marketplace plugin whoseplugin.jsonlacks$schema: the agent server fails to load it while sending the initial message and returns HTTP 500 with the cause in the body. None of that reached the user or the logs.The body was dropped at every hop. The agent server's unhandled-exception handler puts the message in the
exceptionfield (with anerror_id) and setsdetailtoInternal Server Error. The app server's_exception_detailstoredstr(httpx.HTTPStatusError)as the start task detail, which is onlyServer error '500 Internal Server Error' for url '<sandbox url>'. The Slack view then raised a plainRuntimeErrorfor a failed start, and the follow-up path replaced the HTTP error with a fixedException('Failed to send message to v1 conversation'), sostart_jobfell through to its catch-all in both cases.Summary
agent_server_error_detail(openhands/app_server/event_callback/util.py): reads the agent server'sexceptionordetailfield (string or{message}dict) and appendsHTTP <status>anderror_id. With no readable body it returnsAgent server error: HTTP <status>, so the sandbox URL is never shown to a user._exception_detail(live_status_app_conversation_service.py): routeshttpx.HTTPStatusErrorthrough that helper, so a rejected create reports the body's message in the start task detail. The existing secret redaction of the detail is unchanged. This is also what the Canvas start-task card and the other integrations' logs show.integrations/slack/slack_view.py): a failed start raisesStartingConvoException('Failed to start the conversation: <detail>')instead ofRuntimeError, and a rejected follow-up message raisesStartingConvoException('Failed to send your message to the conversation: <detail>')with the body redacted the same way the app server redacts task details.start_jobalready posts that exception's message in the thread, soslack_manager.pyis unchanged.error_id;start_jobposts the message; a rejected create carries the body's message in the start task detail; a non-JSON agent-server error reports the status without the URL.For the reproduction, the Slack thread now reads
Failed to start the conversation: Unsupported or missing $schema in /home/openhands/.openhands/cache/plugins/<package>/plugin.json: None. Supported: https://agent-plugins.org/schemas/1.0.0/plugin.schema.json (HTTP 500, error_id=<id>).Issue Number
Fixes #745
How to Test
uv run pytest -q tests/unit/integrations/slack/test_slack_view.py \ tests/unit/test_slack_integration.py \ tests/unit/app_server/test_live_status_app_conversation_service.py # 315 passed (5 new) uv run pre-commit run --config ./dev_config/python/.pre-commit-config.yaml --files \ integrations/slack/slack_view.py \ openhands/app_server/event_callback/util.py \ openhands/app_server/app_conversation/live_status_app_conversation_service.py \ tests/unit/integrations/slack/test_slack_view.py \ tests/unit/test_slack_integration.py \ tests/unit/app_server/test_live_status_app_conversation_service.pyThe five new tests fail on
main(the Slack views raiseRuntimeError/httpx.HTTPStatusError, and the start task detail is httpx's status-and-URL string) except thestart_jobrelay test, which pins the existing behavior the fix relies on.Outside the unit tests I fed
agent_server_error_detailrealhttpx.Responseobjects for the shapes the pinned agent server 1.58.1 produces: an unhandled 500 (detail+exception+error_id), a 429 with a stringdetail, a{code, message}detail, a non-JSON 502 from a proxy, an emptydetail, and a 422 listdetail. None of the results contain the request URL.Not tested: a live Slack run against a sandbox with a broken plugin.
Video/Screenshots
Not applicable: backend only, no UI change.
Type
Notes
Uh oh!remains the fallback for exceptions that are not a start task error or an agent-server HTTP error.RuntimeErrorfor a failed start and show their generic message (their logs gain the real cause through_exception_detail); the custom-sandbox-image SDK-mismatch hint from feat: surface a clear error when a custom sandbox image's agent-server SDK mismatches OpenHands#14883 still replaces the body on a 500; the follow-up path'sRuntimeErrors for a deleted conversation or a sandbox that never resumes are tracked in OHE-3190.Enterprise server image for this PR: